/**
 * Copyright 2013 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.ServiceObjectType;
import com.viettel.core.enumtype.ServicesHistoryStatus;
import com.viettel.core.enumtype.ServicesHistoryType;

/**
 *  TABLE DICH VU DANG KY
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 18:19:47
 */
@Entity
@Table(name = "SERVICES_HISTORY")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "SERVICES_HISTORY_SEQ", allocationSize = 1)
public class ServicesHistory  implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3833431687252551172L;
	
	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="SERVICES_HISTORY_ID_PK")
	private Integer id;
	
	/**
	 * TEN DICH VU
	 */
	@Basic
	@Column(name = "NAME", length = 200)
	private String name;
	
	/**
	 * TEN DICH VU KHONG DAU
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 200)
	private String nameText;
	
	/**
	 * ID DICH VU THEO LOAI
	 */
	@Basic
	@Column(name = "OBJECT_ID", columnDefinition = "NUMBER(10,0)")
	private Integer objectId;

	/**
	 * LOAI DICH VU: BAI VIET/HUONG DAN NONG NGHIEP
	 */
	@Basic
	@Column(name = "OBJECT_TYPE", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.ServiceObjectType"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="SERVICE_OBJECT_TYPEX")
	private ServiceObjectType objectType;
	
	/**
	 * LOAI DICH VU THEO THANG/NGAY/CHU KY
	 */
	@Basic
	@Column(name = "TYPE", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.ServicesHistoryType"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="SERVICES_HISTORY_TYPEX")
	private ServicesHistoryType type;
	
	/**
	 * GIA HAN DICH VU
	 */
	@Basic
	@Column(name = "IS_RENEWED", columnDefinition = "NUMBER(1,0)")
	private Integer isRenewed;
	
	/**
	 * TRANG THAI
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.ServicesHistoryStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="SERVICES_HISTORY_STATUSX")
	private ServicesHistoryStatus status;
	
	/**
	 * LOAI NONG NGHIEP
	 */
	@ManyToOne(targetEntity = GroupCategory.class)
	@JoinColumn(name = "GROUP_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "SERVICES_HISTORY_CATEGORY_FK")
	private GroupCategory groupCategory;
	
	/**
	 * TO BAO
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "SERVICES_HISTORY_MEDIA_FK")
	private Media media;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public ServicesHistoryType getType() {
		return type;
	}

	public void setType(ServicesHistoryType type) {
		this.type = type;
	}

	public ServicesHistoryStatus getStatus() {
		return status;
	}

	public void setStatus(ServicesHistoryStatus status) {
		this.status = status;
	}

	public GroupCategory getGroupCategory() {
		return groupCategory;
	}

	public void setGroupCategory(GroupCategory groupCategory) {
		this.groupCategory = groupCategory;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public Integer getObjectId() {
		return objectId;
	}

	public void setObjectId(Integer objectId) {
		this.objectId = objectId;
	}

	public ServiceObjectType getObjectType() {
		return objectType;
	}

	public void setObjectType(ServiceObjectType objectType) {
		this.objectType = objectType;
	}

	public Integer getIsRenewed() {
		return isRenewed;
	}

	public void setIsRenewed(Integer isRenewed) {
		this.isRenewed = isRenewed;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	
}
